home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_097 / graphit / help.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  9KB  |  305 lines

  1. /****************************************************************************/
  2. /*   Program: Graph It II    (The C Program)                                    */
  3. /*   SubModule:    help.c  1-20-87                                                */
  4. /*   CopyRight By Flynn D. Fishman  January 1987                            */
  5. /*    Feel Free to copy and alter this source                                    */
  6. /****************************************************************************/
  7. /* This module contains the title page and help text as well as the
  8.     subroutines for the help screen                                            */
  9.  
  10. #include "graph.h"
  11.  
  12. static char *(HelpPages[]) =
  13. {
  14. "0",
  15. "Graph It  II   The sequal In 3D",
  16. "By Flynn D. Fishman Copyright January 1987",
  17. " ",
  18. "Feel free to copy this program and give it anyone you wish.",
  19. "As long as you do not make any money on the transaction",
  20. "Or remove this notice and my name",
  21. " ",
  22. "Use the ? icon for more help or the Y= icon to enter a function",
  23. "Although load and save do not work you can also use pull down menus",
  24. " ",
  25. "     Please send any comments (Debugs) to:",
  26. "        Flynn D. Fishman",
  27. "        32 WoodBrook Court S.W. Calgary",
  28. "        Alberta, Canada, T2W-4G1",
  29. "   or   UseNet (UUCP):ihnp4!watmath!watcgl!fdfishman",
  30. " ",
  31. "Although the code is no longer recognizable as his",
  32. "I would like to thank Richard M. Ross, Jr. for writing",
  33. "Free Draw from which I took some Intuition code.",
  34. "1",
  35. "Page 1                         Introduction",
  36. " ",
  37. "Graph It allows you to enter almost any function",
  38. "and see it plotted (In 2 or 3 dimensions)",
  39. "functions are entered using the command line and",
  40. "several paramters can be changed with the mouse",
  41. " ",
  42. "A couple of notes",
  43. " 1. This program is not 100% finished yet so some of",
  44. "    the functionality of the program may seem rough.",
  45. " 2. Although the math parser is quite powerful it does",
  46. "    not know about order of operations, but it does",
  47. "    know about brakets.",
  48. " 3. Note that 3d move and zoom are based on a 2d screen",
  49. " 4. There are currently no error messages if you make",
  50. "    a mistake in entering a formula or command",
  51. "2Icon",
  52. "Page 2                         Icons",
  53. " ",
  54. "The icons on the far right of the screen are as follows:",
  55. "    ZOOM:Allows you to capture part of the graph by" ,
  56. "      clicking, draging and then releasing the left button",
  57. "    MOVE:Allows you to move the graph in the same method",
  58. "      as with zoom but note the constraining boxes",
  59. "    COMMAND:Allows you to enter the desired function or",
  60. "      alter other variables (more later)",
  61. "    HIDDEN SURFACE:The icon toggles between removing",
  62. "      covered surfaces (3d Graph only)",
  63. "    HOME:Returns the graph to 0,0 and places all the" ,
  64. "      variables in the default setting",
  65. "    QUIT:Exit the program",
  66. " ",
  67. "    HELP:Gives you these pages",
  68. "3",
  69. "Page 3                         Functions",
  70. " ",
  71. "To enter a function just click on the command icon and then",
  72. "enter your function i.e. y=sin(x), z=x-y or x=t, y=sin(t) ",
  73. "after entering your function you can enter another command",
  74. "or enter a blank line to exit command mode.  Note if you enter",
  75. "an invalid command you will not be able to exit command mode",
  76. "until you enter a valid command.",
  77. " ",
  78. "Notes",
  79. " 1. If you enter a function for z or x you are automatically",
  80. "    placed in 3d mode or parametric mode respectively.",
  81. " 2. To erase a function simply type z= this will put you",
  82. "    back into 2d mode (or y= is also acceptable)",
  83. " ",
  84. "Current allowable functions include:",
  85. "  cos, sin, tan, exp, PI, E, atan, asin, acos, ln",
  86. "  + - * / ^",
  87. "4",
  88. "Page 4                         Other Commands",
  89. " ",
  90. "Other Commands include:",
  91. "xstart=  to set the origional x value.",
  92. "xend=     to set the last x value.",
  93. "xlabels= to set the label values on the x-axis.",
  94. "              (Not Implemented Yet)",
  95. " ",
  96. "ystart=  to set the origional y value.",
  97. "yend=     to set the last y value.",
  98. "ylabels= to set the label values on the y-axis.",
  99. "              (Not Implemented Yet)",
  100. " ",
  101. "detail=  the number of pixels per calculated function",
  102.         " for example detail=1 calculates a y-value",
  103.         " for each pixel.",
  104. "for example:",
  105. "    xstart=-5,    ystart=5,     detail=5,     yl=1",
  106. "5",
  107. "Page 5                         Other Icons"    ,
  108. " ",
  109. "x-expand: (Bottom Slider) used to increase the area",
  110. "  covered by the x area.",
  111. " ",
  112. "y-expand: (Right Slider) used to increase the area",
  113. "  covered by the y area.",
  114. " ",
  115. "Window-Sizer:(Bottom Left) standard window resize" ,
  116. "  gadget",
  117. " ",
  118. "Close Gadget:(Top Right) standard window close gadget",
  119. " ",
  120. "Window in front and behind",
  121. "6",
  122. };
  123.  
  124. Help(Window, parameters)
  125. struct Window *Window;
  126. struct Graph_Parameters *parameters;
  127.     {
  128.     int page, KeepGoing, status;
  129.  
  130.     KeepGoing = TRUE;
  131.     page = FIRSTPAGE;
  132.  
  133.     while (KeepGoing)
  134.         {
  135.         PrintPage(Window, page);
  136.         status = GetPush(Window);
  137.         if (status == FORWARD) page++;
  138.         if (page > LASTPAGE) page = FIRSTPAGE;
  139.         if (status == BACKWARD) page--;
  140.         if (page < FIRSTPAGE) page = LASTPAGE;
  141.         if (status == QUIT) KeepGoing = FALSE;
  142.         }
  143.  
  144.     DrawWindow(Window, parameters);
  145.     PlotGraph(Window, parameters);
  146.     }
  147.  
  148. PrintPage(Window, page)
  149. struct Window *Window;
  150. int page;
  151.     {
  152.     int current_line, first_line, row;
  153.     int minx, miny, maxx, maxy;
  154.     char line[5];
  155.  
  156.     if (page > LASTPAGE) return(FALSE);
  157.  
  158.     minx = Window->BorderLeft;
  159.     miny = Window->BorderTop;
  160.     maxx = Window->Width - Window->BorderRight - XBORDER;
  161.     maxy = Window->Height - Window->BorderBottom - YBORDER;
  162.  
  163.     DrawRectangle(Window, 2l, minx, miny, maxx, maxy);
  164.  
  165.     sprintf(line, "%ld", page);
  166.  
  167.     current_line = 0;
  168.     while(line[0] != HelpPages[current_line++][0] );
  169.  
  170.     sprintf(line, "%ld", ++page);
  171.  
  172.     row = 0;
  173.     first_line = current_line - 1;
  174.     while(line[0] != HelpPages[current_line][0] )
  175.         Print(Window, HelpPages[current_line++], row++);
  176.     if (HelpPages[first_line][1] == 'I')
  177.         DrawImages(Window, minx+12, miny+(ICONY+2) + 10);
  178.     }
  179.  
  180. struct TextAttr myfont =
  181.     {
  182.     "topaz.font",
  183.     8, 0, 0
  184.     };
  185.  
  186. struct IntuiText textout =
  187.     {
  188.     1, 0,        /* Pen Colours                */
  189.     JAM2,        /* Drawing mode             */
  190.     0, 0,        /* Position offsets            */
  191.     &myfont,    /* Font                        */
  192.     NULL,        /* Text (To insert later)    */
  193.     NULL        /* next string                */
  194.     };
  195.  
  196. Print(Window, text, line)
  197. struct Window *Window;
  198. char text[];
  199. long int line;
  200.     {
  201.     long int minx, miny, maxx, maxy;
  202.     long y;
  203.  
  204.     minx = Window->BorderLeft;
  205.     miny = Window->BorderTop;
  206.     maxx = Window->Width - Window->BorderRight - XBORDER;
  207.     maxy = Window->Height - Window->BorderBottom - YBORDER;
  208.  
  209.     y = miny + 2 + line * (ICONY + 2) / 2;
  210.     if ( y > maxy) y = maxy;
  211.  
  212.     textout.IText = text;
  213.     PrintIText(Window->RPort, &textout, minx +5, y);
  214.     }
  215.  
  216. GetPush(Window)
  217. struct Window *Window;
  218.     {
  219.     struct IntuiMessage *NewMessage;    /* msg structure for GetMsg() */
  220.     ULONG class;                        /* used in message monitor loop */
  221.     USHORT code;                         /* used in message monitor loop */
  222.     long int x, y;
  223.     int no_button;
  224.  
  225.     long int minx, miny, maxx, maxy;
  226.  
  227.     minx = Window->BorderLeft;
  228.     miny = Window->BorderTop;
  229.     maxx = Window->Width - Window->BorderRight - XBORDER;
  230.     maxy = Window->Height - Window->BorderBottom - YBORDER;
  231.  
  232.     PrintHelpIcons(Window);
  233.  
  234.     while( NewMessage=(struct IntuiMessage *)GetMsg(Window->UserPort) )
  235.     no_button = TRUE;
  236.  
  237.     while (no_button)
  238.         {
  239.         Wait( 1 << Window->UserPort->mp_SigBit);
  240.         while( NewMessage=(struct IntuiMessage *)GetMsg(Window->UserPort) )
  241.             {
  242.             class = NewMessage->Class;
  243.             ReplyMsg( NewMessage );
  244.             if (class == MOUSEBUTTONS)
  245.                 {
  246.                 x = Window->MouseX;
  247.                 y = Window->MouseY;
  248.                 if (y > maxy - 10)
  249.                     {
  250.                     if ( x < maxx / 3) return (FORWARD);
  251.                     if ( x > maxx / 3 * 2) return (BACKWARD);
  252.                     else return (QUIT);
  253.                     }
  254.                 }
  255.             }  /* end of message lists */
  256.  
  257.         }      /* end of nobuttons */
  258.     }         /* end of routines  */
  259.  
  260. PrintHelpIcons(Window)
  261. struct Window *Window;
  262.     {
  263.     long int minx, miny, maxx, maxy, x, y;
  264.  
  265.     minx = Window->BorderLeft;
  266.     miny = Window->BorderTop;
  267.     maxx = Window->Width - Window->BorderRight - XBORDER;
  268.     maxy = Window->Height - Window->BorderBottom - YBORDER;
  269.  
  270.     SetDrMd(Window->RPort, JAM2);
  271.  
  272.     y = maxy - 2;
  273.     x = minx + 6;
  274.     SetAPen(Window->RPort, 3l);
  275.     SetBPen(Window->RPort, 3l);
  276.     Move(Window->RPort, x, y);
  277.     Text(Window->RPort, " Next Page ", 11l);
  278.     SetAPen(Window->RPort, 1l);
  279.     SetBPen(Window->RPort, 2l);
  280.     Move(Window->RPort, x-1, y-1);
  281.     Text(Window->RPort, " Next Page ", 11l);
  282.  
  283.     y = maxy - 2;
  284.     x = minx + 6 + maxx / 3;
  285.     SetAPen(Window->RPort, 3l);
  286.     SetBPen(Window->RPort, 3l);
  287.     Move(Window->RPort, x, y);
  288.     Text(Window->RPort, " Go To Graph ", 13l);
  289.     SetAPen(Window->RPort, 1l);
  290.     SetBPen(Window->RPort, 2l);
  291.     Move(Window->RPort, x-1, y-1);
  292.     Text(Window->RPort, " Go To Graph ", 13l);
  293.  
  294.     y = maxy - 2;
  295.     x = minx + 6 + maxx / 3 * 2;
  296.     SetAPen(Window->RPort, 3l);
  297.     SetBPen(Window->RPort, 3l);
  298.     Move(Window->RPort, x, y);
  299.     Text(Window->RPort, " Previous Page ", 15l);
  300.     SetAPen(Window->RPort, 1l);
  301.     SetBPen(Window->RPort, 2l);
  302.     Move(Window->RPort, x-1, y-1);
  303.     Text(Window->RPort, " Previous Page ", 15l);
  304.     }
  305.